package com.he.test;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/10/24 8:27
 */
public class Client {

    public static void main(String[] args) {
        //饿汉式创建单例模式（程序运行时创建对象）
        StaticSingleton instance1 = StaticSingleton.getInstance();
        StaticSingleton instance2 = StaticSingleton.getInstance();
        System.out.println(instance1);
        System.out.println(instance2);
        System.out.println(instance1 == instance2);
        instance1.show();
        System.out.println("=============================");

        //懒汉式创建单例模式（第一次调用时创建对象）
        SyncSingleton instance3 = SyncSingleton.getInstance();
        SyncSingleton instance4 = SyncSingleton.getInstance();
        System.out.println(instance3);
        System.out.println(instance4);
        System.out.println(instance3 == instance4);
        instance3.show();
        System.out.println("=============================");
        SyncSingletonStatic instance5 = SyncSingletonStatic.getInstance();
        SyncSingletonStatic instance6 = SyncSingletonStatic.getInstance();
        System.out.println(instance5);
        System.out.println(instance6);
        System.out.println(instance5 == instance6);
        instance5.show();

    }
}
